# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=restler-fuzzer
pkgver=427.9356588
pkgrel=1
epoch=8
pkgdesc='First stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.'
arch=('x86_64')
groups=('blackarch' 'blackarch-webapp'  'blackarch-fuzzer')
url='https://github.com/microsoft/restler-fuzzer'
license=('MIT')
depends=('python' 'dotnet-sdk')
makedepends=('git')
source=("git+https://github.com/microsoft/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin/"

  python ./build-restler.py --dest_dir "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" docs/*/* README.md

  chmod 755 "$pkgdir/usr/share/$pkgname/engine/restler.py"

  sed -i '1 i\#!/usr/bin/python' "$pkgdir/usr/share/$pkgname/engine/restler.py"

  ln -sf "/usr/share/$pkgname/engine/restler.py" "$pkgdir/usr/bin/$pkgname"
}

